package com.chain.BrotherExchange.ui.activity;

import android.content.res.AssetManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Environment;
import android.widget.VideoView;

import com.chain.BrotherExchange.R;
import com.chain.BrotherExchange.ui.core.BaseActivity;
import com.chain.BrotherExchange.utils.ActivityBarHelper;
import com.chain.BrotherExchange.utils.Androids;

import java.io.IOException;

import butterknife.Bind;

public class LaunchActivity extends BaseActivity {

    @Bind(R.id.launch_video)
    VideoView mVideoView;

    @Override
    protected void setStatusBar() {
        ActivityBarHelper.setTransparentStatus(this);
    }

    @Override
    protected int getLayoutID() {
        return R.layout.activity_launch;
    }

    @Override
    protected void initActions() {
        mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.launch_video));
        mVideoView.start();
        mVideoView.requestFocus();
        mVideoView.setOnCompletionListener(mp -> {
            MainActivity.launch(this);
            finish();
        });

        // 语言
        Androids.alertLanguage(this, Androids.LocalConfig.getLanguage());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mVideoView != null) {
            mVideoView.pause();
            mVideoView.stopPlayback();
            mVideoView.suspend();
        }
    }
}
